//Source file: D:\\test\\com\\ce\\pms\\custservice\\model\\AbstractQuestionaire.java

package com.ce.pms.custservice.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.ce.pms.common.model.SysInfo;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.house.model.HouseDomain;
import com.ce.pms.system.custservice.model.ReturnVisitWayDO;
import com.sitechasia.webx.core.model.IDomainObject;

/**
 * 实体名称:调查问卷 关联数据表:CE_QUESTIONAIRE
 *
 * @author yandawei
 * @CreateDate:2008-12-8
 */
@Entity
@Table(name = "CE_QUESTIONAIRE")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "CLAZZ", discriminatorType = DiscriminatorType.STRING)
public abstract class AbstractQuestionaire implements IDomainObject {


	/**
	 * 回访问卷ID
	 */
	@Id
	@GeneratedValue
	@Column(name = "QUESTIONAIRE_ID")
	private Long keyword;

	/**
	 * 回访人
	 */
	@Column(name = "RECORDER", nullable = false, length = 36)
	private String recorder;

	/**
	 * 回访时间
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "RECORD_TIME", nullable = false)
	private Date recordTime;

	/**
	 * 总结
	 */
	@Column(name = "SUMMARIZE", length = 200)
	private String summarize;

	/**
	 * 数据状态:1正常;0作废
	 */
	@Column(name = "VALIDITY", nullable = false, length = 1)
	private String validity;

	/**
	 * 客户姓名
	 */
	@Column(name = "CLIENT", nullable = false,length = 36)
	private String client;

	/**
	 * 房号
	 */
	@Column(name = "HOUSE_NUMBER", length = 36)
	private String houseNumber;

	/**
	 * 房间ID
	 */
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="HOUSE_ID")
	private HouseDomain house;

	/**
	 * 回访方式
	 */
	@OneToOne(fetch= FetchType.LAZY)
	@JoinColumn(name="RETURN_VISIT_WAY_ID")
	private ReturnVisitWayDO returnVisitWayDO;

	/**
	 * 客户事件
	 */
	@ManyToOne(fetch= FetchType.LAZY)
	@JoinColumn(name="CUST_SERVICE_EVENT_ID")
	private CustServiceEventDO customerServiceEventDO;

	/**
	 * 题目与答案
	 */
	@OneToMany(fetch = FetchType.LAZY,mappedBy="abstraQuestionaire",cascade ={CascadeType.ALL})
	private Set<QuestionAndAnswer> questionAndAnswerSet = new HashSet<QuestionAndAnswer>();

	/***
	 *  备注
	 */
	@Column(name="REMARK",length=400)
	private String remark;

	/**
	 * 系统信息
	 */
	@Embedded
	private SysInfo sysInfo;

	/**
	 * @roseuid 4937AB2A0242
	 */
	public AbstractQuestionaire() {
		initValidity();
	}

	/**
	 * 自定义构造方法
	 * @param keyword 回访问卷ID
	 */
	public AbstractQuestionaire(Long keyword,SysInfo sysInfo) {
		this.keyword = keyword;
		this.sysInfo = sysInfo;
		initValidity();
	}


	/**
	 * 设置状态”正常" validity=1
	 *
	 * @roseuid 492417F500BB
	 */
	private void initValidity() {
		setValidity(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
	}

	/**
	 * 设置状态”作废" validity=0
	 *
	 * @roseuid 492418400109
	 */
	public void setValidityFalse() {
		setValidity(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO);
	}

	/**
	 * 写入答题
	 *
	 * @param answer
	 * @roseuid 492418F60196
	 */
	public void addAnswer(QuestionAndAnswer answer) {
		this.getQuestionAndAnswerSet().add(answer);
	}

	public String getClient() {
		return client;
	}

	public void setClient(String client) {
		this.client = client;
	}

	public CustServiceEventDO getCustomerServiceEventDO() {
		return customerServiceEventDO;
	}

	public void setCustomerServiceEventDO(CustServiceEventDO customerServiceEventDO) {
		this.customerServiceEventDO = customerServiceEventDO;
	}

	public String getHouseNumber() {
		return houseNumber;
	}

	public void setHouseNumber(String houseNumber) {
		this.houseNumber = houseNumber;
	}

	public Long getKeyword() {
		return keyword;
	}

	public void setKeyword(Long keyword) {
		this.keyword = keyword;
	}

	public Set<QuestionAndAnswer> getQuestionAndAnswerSet() {
		return questionAndAnswerSet;
	}

	public void setQuestionAndAnswerSet(Set<QuestionAndAnswer> questionAndAnswerSet) {
		this.questionAndAnswerSet = questionAndAnswerSet;
	}

	public String getRecorder() {
		return recorder;
	}

	public void setRecorder(String recorder) {
		this.recorder = recorder;
	}

	public Date getRecordTime() {
		return recordTime;
	}

	public void setRecordTime(Date recordTime) {
		this.recordTime = recordTime;
	}

	public ReturnVisitWayDO getReturnVisitWayDO() {
		return returnVisitWayDO;
	}

	public void setReturnVisitWayDO(ReturnVisitWayDO returnVisitWayDO) {
		this.returnVisitWayDO = returnVisitWayDO;
	}

	public String getSummarize() {
		return summarize;
	}

	public void setSummarize(String summarize) {
		this.summarize = summarize;
	}

	public String getValidity() {
		return validity;
	}

	public void setValidity(String validity) {
		this.validity = validity;
	}

	public SysInfo getSysInfo() {
		return sysInfo;
	}

	public void setSysInfo(SysInfo sysInfo) {
		this.sysInfo = sysInfo;
	}

	public HouseDomain getHouse() {
		return house;
	}

	public void setHouse(HouseDomain house) {
		this.house = house;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}


}
